# 作者：宋安康
# 开发时间：2023/6/11 16:55
import socket

HOST = '192.168.31.199'
PORT = 5050

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((HOST, PORT))
server_socket.listen()

client_socket, address = server_socket.accept()
print(f"Connection from {address} has been established.")
while True:
    msg = client_socket.recv(1024).decode()
    print(f"Received message: {msg}")
    if msg == "quit":
        break
    reply = input("Enter a reply message: ")
    client_socket.send(reply.encode())

client_socket.close()
